home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Info-Mac 4
/
Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso
/
Science
/
MandelZot 4.0.1 docs Folder
/
ECI.h
next >
Wrap
Text File
|
1993-05-16
|
17KB
|
459 lines
/*
Data definitions for the MandelZot external function
interface.
*/
#include <Types.h>
#define ECIVERSION 0x0100 /* version 1.0 per Apple's numbering style */
typedef union Arg /* Argument variants */
{
void *p; /* generic pointer */
Handle h; /* generic handle */
char c; /* single character */
char bool; /* one-byte boolean */
short int si; /* 16-bit integer */
long int li; /* 32-bit integer */
long int flags; /* 32 one-bit flags */
float f; /* SANE/IEEE single-precision floating */
short double d; /* SANE/IEEE double-precision floating */
double e; /* SANE *or* IEEE extended-precision */
Rect r; /* QuickDraw rectangle */
char filler[12];
} Arg;
typedef struct ECD /* External Code descriptor */
{
Handle private; /* handle to module-specific private data, if any */
int resFileRefNum;/* refNum of resource file, if open... or 0 */
long int opaque[]; /* remainder of structure is opaque to the ECM */
} ECD, **ECDHandle;
typedef struct ECP /* External Code parameter structure */
{
long int functionCode; /* function code being requested */
Arg arg[16]; /* up to 16 arguments per call */
} ECP, **ECPHandle;
typedef struct ECO /* External Code overhead structure */
{
ECDHandle ECD; /* handle to code descriptor structure */
Handle viewHandle; /* opaque handle to view structure */
Handle private; /* handle to view-specific private data, if any */
pascal long int (*util)(struct ECO **,
struct ECP *); /* pointer to MandelZot "pascal" utility callback */
} ECO, **ECOHandle;
/*
Data bits describing ECM's requirements
*/
#define NeedFPU 0x80000000
#define NeedIEEEformat 0x40000000
#define NeedResources 0x20000000
#define NeedLockSelf 0x10000000
#define NeedLockAll 0x08000000
#define NeedConfigure 0x04000000
/*
Data bits describing ECM's capabilities
*/
#define DoMarianiSilver 0x80000000
#define DoDistEstimator 0x40000000
#define DoJulias 0x20000000
#define DoByPoint 0x10000000
#define DoByBatch 0x08000000
#define DoBroadband 0x04000000
#define DoSyncOrbits 0x02000000
/*
Data bits describing symmetry
*/
#define SymmetryHoriz 0x0001
#define SymmetryVert 0x0002
#define SymmetryOrigin 0x0004
/*
Data bits describing math modes supported/used
*/
#define Math16bit 0x0001
#define Math32bit 0x0002
#define MathSANE 0x0004
#define Math881 0x0008
/*
Values returned from the CalcTimeSlice call
*/
#define SliceSuspend -1
#define SliceOK 0
#define SliceIdle 1
#define SliceDone 2
/*
File and resource types etc.
*/
#define CustomFileType 'CUST'
#define CustomResType 'CUST'
#define CustomResID 0
#define CustomResRange 1024
#define CustomResRangeEnd 2047
/*
Values and masks for dwell counts.
Dwell values are stored in 16-bit integers. The rightmost 15 bits
are the dwell value (in the range 0 through 32765), or "in the M-set"
(32766) or "unknown at this time" (32767). The leftmost bit is a flag
used to indicate that the value in the rightmost 15 bits is approximate
or inexact, and should be recalculated; this bit is set when a window is
resized upwards, or the calculation parameters are changed.
*/
#define MaxLegalDwell 32765
#define InTheSet 32766
#define Unknown 32767
#define RecalcBit 0x8000
#define DwellMask 0x7FFF
/*
Function codes passed in to ECM from the program
*/
enum ECFunction
{
GetGeneralInfo = 0,
InitECM = 1,
GetDefaults = 2,
SetupView = 3,
ConfigureView = 4,
SetupCalcs = 5,
CalcsGo = 6,
CalcsStop = 7,
CalcOne = 8,
CalcTimeSlice = 9,
KillView = 10,
KillECM = 11,
GetViewInfo = 12,
InvalInternals = 13,
GetViewString = 14,
InitIncrementalState = 15,
CalcIncremental = 16
};
/*
Parameter definitions for the various callins
"->" represents a value passed into the ECM
"<-" represents a value filled in by the ECM prior to returning.
---
GetGeneralInfo. Called during program initialization. ECM should fill in
specified values and return, taking no other actions. [N.B. This is the
only callin which can occur before the first InitECM.]
[0].si -> Interface version against which program was compiled.
[0].si <- Interface version number against which the ECM was
compiled. If too old, ECM will not be usable.
[1].flags <- "Needs" flags, or'ed together
[2].flags <- "Does" flags, or'ed together.
[3].flags <- "Math" flags, or'ed together
---
InitECM. Called when ECM's code resource is first read in. ECM should set
up any desired global-state code, storing handle into the ECD structure.
No data is passed in or out.
---
GetDefaults. Called during the "New view" dialog, when an ECM is selected from
the popup menu, or when the julia-set status box changes.
[0].bool -> if true, the ECM should return the appropriate default
values for a Julia-set image. If false, the ECM should
return the appropriate defaults for an M-like image.
[0].d <- Minimum real value displayed in window
[1].d <- Maximum real value displayed in window
[2].d <- Minimum imaginary value displayed in window
[3].d <- Maximum imaginary value displayed in window
[4].si <- Dwell limit [0..32765]
[5].d <- Escape radius
[6].d <- Julia control point, real (iff julia image requested)
[7].d <- Julia control point, imaginary (iff julia image requested)
---
ConfigureView. Called when the user presses the "Setup" botton in the
New View dialog box (and also when the ECM is initially selected from
the popup menu). The ECM may pop up a dialog box to allow
the user to enter configuration information (e.g. equation coefficients,
network-server name/ID, etc.). All such data should be stored in a relocatable
block allocated by the ECM, whose handle is stored in the ECO structure.
This routine may be called multiple times, to update the configuration.
[0].bool -> nonzero if Julia calculation, zero if M calculation
---
SetupView. Called after the user clicks OK during the creation of a new view.
This callin is a relict of an older version of MandelZot, and no existing ECMs make
any use of it (they do the work at ConfigureView or SetupCalcs time instead).
No parameters are passed in at this time. Returning an error code will cause the
creation of the new view to be aborted.
---
GetViewInfo. Called after the view data structure has been initialized, and
before calculation begins. ECM must return information about the characteristics
of the view: whether the distance-estimator feature is available, whether the
Mariani-Silver algorithm should be enabled, information concerning the symmetry
of the resulting image, etc.
[0].e -> Minimum real value displayed in window
[1].e -> Maximum real value displayed in window
[2].e -> Minimum imaginary value displayed in window
[3].e -> Maximum imaginary value displayed in window
[4].si -> Dwell limit [0..32765]
[5].d -> Escape radius
[6].bool -> nonzero if Julia calculation, zero if M calculation
[7].e -> Julia control point, real (iff julia image requested)
[8].e -> Julia control point, imaginary (iff julia image requested)
[0].bool <- nonzero if distance-estimator capability is available
[1].bool <- nonzero if Mariani/Silver algorithm is suitable
[2].flags <- symmetry characteristics: horizontal, vertical, across-origin,
or an or'ed combination thereof.
[3].e <- real axis of symmetry, if any symmetry is specified
[4].e <- imaginary axis of symmetry, if any symmetry is specified
[5].si <- # of bytes of private context storage required per point during
incremental iteration (must be returned only if synchronous-orbit
capability was specified in the "does" flags)
[9].bool <- nonzero if the Sherman contour crawling algorithm is safe to use
[10].bool <- nonzero if synchronous-orbit mode (CalcIncremental) is available
---
SetupCalcs. Called when the view data structure has been initialized, and
calculation is about to begin. ECM should set up any data it needs to perform
the calculation, based on the current calculation parameters. May be called
more than once, if the user changes the calculation parameters.
[0].e -> Minimum real value displayed in window
[1].e -> Maximum real value displayed in window
[2].e -> Minimum imaginary value displayed in window
[3].e -> Maximum imaginary value displayed in window
[4].si -> Dwell limit [0..32765]
[5].d -> Escape radius
[6].bool -> nonzero if Julia calculation, zero if M calculation
[7].e -> Julia control point, real (iff julia image requested)
[8].e -> Julia control point, imaginary (iff julia image requested)
[9].bool -> nonzero if distance-estimator, zero if point-by-point
[10].r -> Rectangle framing the window
---
CalcsGo. Called when the program has decided to start calling CalcTimeSlicd.
ECM should grab any resources needed to do calculation (external hardware,
network calculation server, etc.).
No parameters at this time; success is assumed.
---
CalcsStop. Called when the program has decided to stop calling CalcTimeSlice.
ECM should release any resources it grabbed at CalcsGo time.
No parameters at this time; success is assumed.
---
CalcOne. Called to request calculation of the dwell (and, optionally,
distance-to-nearest-interior-point) of a single point.
[0].e -> Real coordinate of point
[1].e -> Imaginary coordinate of point
[2].si -> Dwell limit
[3].d -> Escape radius
[4].bool -> nonzero if Julia calculation, zero if M calculation
[5].bool -> nonzero if distance-estimator, zero if point-by-point
[6].e -> Julia control point, real (iff julia image requested)
[7].e -> Julia control point, imaginary (iff julia image requested)
[8].flags -> Flag indicating math mode in use
[0].si <- Dwell of point [0..limit), or
"on border" == limit, or
"in M" == 32766 (InTheSet).
[1].e <- Estimated distance to nearest interior point (iff
distance-estimator mode), or -1 == "beats me!"
---
CalcTimeSlice. Called to give a bulk-calculation-mode ECM an opportunity to
calculate something. CalcTimeSlice calls will occur in the middle of a
CalcGo/CalcStop pair. ECM should do some calculating, if possible; stuff
dwell values into the array; and use callbacks to instruct the program to
display points/lines/rectangles of data values on the screen. ECM can draw to
the window if desired (it's the current GrafPort).
[0].e -> Minimum real value displayed in window
[1].e -> Maximum real value displayed in window
[2].e -> Minimum imaginary value displayed in window
[3].e -> Maximum imaginary value displayed in window
[4].si -> Dwell limit [0..32765]
[5].d -> Escape radius
[6].bool -> nonzero if Julia calculation, zero if M calculation
[7].e -> Julia control point, real (iff julia image requested)
[8].e -> Julia control point, imaginary (iff julia image requested)
[9].bool -> nonzero if distance-estimator, zero if point-by-point
[10].r -> Rectangle framing the window
[11].r -> Rect which frames entire array (if calculation is not currently
constrained) or frames constrained area. ECM should limit its
calculations and drawing to points within this rectangle.
[12].h -> Handle to array of dwell values, stored in row-major order
[13].flags -> Flag indicating math mode in use
[0].si <- SliceOK if all is well and useful work was done;
SliceIdle if all is well but nothing much happened (little time used);
SliceDone if all is well and calculations for the area framed by
the [11].r parameter have been completed;
SliceSuspend if something has gone awry and calculations should
be suspended until the user hits command-G again.
---
InvalInternals. Called when MandelZot loads a view's private data from a save-
file, or after an "Extract selection" command. Call informs ECM that any pointers
or handles stashed in the view's private data block are no longer valid... they may
point to the parent window's private data (after an "Extract selection) or to
memory locations from a former lifetime (after loading a save-file). ECM should zap
any pointers or handles (reset them to NULL, or allocate new blocks of the necessary
sizes and replace the old handles). ECM should _not_ attempt to access, or dispose of
blocks referenced by the invalidated handles or pointers... they're off limits!!
---
GetViewString. Called when the program wants a human-readable interpretation
of the view's private data. ECM should convert relevant portions of the
private data (e.g. polynomial coefficients, exit conditions, etc.) to printable
form, and return them in the form of a PASCAL string of up to 255 characters.
[0].p -> Pointer to an Str255 (PASCAL string) of indeterminate
contents; program should stuff string into this structure.
---
InitIncrementalState. Called when the program is about to begin incremental
iteration on set of points in synchronous-orbit mode. ECM must initialize the
block of data identified by the given handle to a state which reflects "iteration
zero" of a point. Called only if the ECM specified a non-zero amount of private
state information.
[0].h -> Handle to an unlocked relocateable block which ECM should
initialize to reflect "iteration zero" status.
---
CalcIncremental. Called during synchronous-orbit operation, to iterate a single
point one step further along its trajectory.
[0].e -> Real coordinate of iterated point
[1].e -> Imaginary coordinate of iterated point
[2].e -> Real coordinate of original (seed) point
[3].e -> Imaginary coordinate of original point
[4].bool -> nonzero if Julia calculation, zero if M calculation
[5].si -> Dwell count prior to iteration
[6].e -> Julia control point, real (iff julia image requested)
[7].e -> Julia control point, imaginary (iff julia image requested)
[8].flags -> Flag indicating math mode in use
[9].d -> Escape radius
[10].ptr -> Pointer to point's private state information
[0].e <- Real coordinate of iterated point (updated)
[1].e <- Imaginary coordinate of iterated point (updated)
[2].bool <- Nonzero if point escaped, zero otherwise
[3].si <- Dwell to color this point, if it escaped ([2].bool nonzero);
irrelevant if point did not escape.
*/
/*
Function codes which the ECM can use when calling back to the main program
*/
enum CallbackFunction
{
DisplayPoint = 100,
DisplayRowSeg = 101,
DisplayRect = 102,
SetPenColor = 103,
SetStatusString = 104
};
/*
Parameter definitions for the various callbacks
"->" represents a value passed by the ECM to the program's callback routine
"<-" represents a value filled in by the callback prior to returning.
DisplayPoint. Used to ask the program to display a specified dwell-point in the
window. ECM must stuff the dwell value into the dwell array before making this
call.
[0].si -> X coordinate of point to be displayed
[1].si -> Y coordinate of point to be displayed
---
DisplayRowSeg. Used to ask the program to display one or more dwell
points in a specified row. ECM must stuff the values into the dwell array before
making this call.
[0].si -> X coordinate at left end of row segment.
[1].si -> X coordinate at right end of row segment.
[2].si -> Y coordinate of row.
---
DisplayRect. Used to ask the program to display a rectangular portion of the
view window, using the current dwell values for those points.
[0].r -> Rect specifying the area to be displayed.
n.b. the display occurs when the call is made. Another way to do this is to
simply InvalRect(&rect); the program will erase and redraw the specified
rectangle the next time around the event loop.
---
SetPenColor. Used to ask the program to set the port's pen to the proper
color for drawing points of a specific dwell.
[0].r -> Dwell value for which pen color should be set.
n.b. ECM should reset the pen to black before returning.
---
SetStatusString. Used to ask the program to update the status advisory
displayed (sometimes) in the horizontal scroll bar area.
[0].p -> Pointer to Pascal Str255 string to be displayed.
n.b. the specified string may or may not actually be displayed, at this
time or later. This feature should be used for "FYI" information only;
it's not suitable for use in developing any sort of real user interface.
*/